/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ecom.beans.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Mariam Soumaré
 */
@Entity
@Table(name = "achats")
@NamedQueries({
    @NamedQuery(name = "Achats.findAll", query = "SELECT a FROM Achats a"),
    @NamedQuery(name = "Achats.findById", query = "SELECT a FROM Achats a WHERE a.id = :id"),
    @NamedQuery(name = "Achats.findByCity", query = "SELECT a FROM Achats a WHERE a.city = :city"),
    @NamedQuery(name = "Achats.findByName", query = "SELECT a FROM Achats a WHERE a.name = :name"),
    @NamedQuery(name = "Achats.findByPrice", query = "SELECT a FROM Achats a WHERE a.price = :price"),
    @NamedQuery(name = "Achats.findByQuantity", query = "SELECT a FROM Achats a WHERE a.quantity = :quantity")})
public class Achats implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Long id;
    @Basic(optional = false)
    @Column(name = "CITY")
    private String city;
    @Basic(optional = false)
    @Column(name = "NAME")
    private String name;
    @Basic(optional = false)
    @Column(name = "PRICE")
    private double price;
    @Basic(optional = false)
    @Column(name = "QUANTITY")
    private String quantity;
    @JoinColumn(name = "ID_PRODUITS", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Produits produits;
    @JoinColumn(name = "ID_COMMANDE", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Commandes commandes;

    public Achats() {
    }

    public Achats(Long id) {
        this.id = id;
    }

    public Achats( String city, String name, double price, String quantity, Commandes commandes, Produits produits ) {
        this.city = city;
        this.name = name;
        this.price = price;
        this.quantity = quantity;
        this.commandes=commandes;
        this.produits=produits;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getQuantity() {
        return quantity;
    }

    public void setQuantity(String quantity) {
        this.quantity = quantity;
    }

    public Produits getProduits() {
        return produits;
    }

    public void setProduits(Produits produits) {
        this.produits = produits;
    }

    public Commandes getCommandes() {
        return commandes;
    }

    public void setCommandes(Commandes commandes) {
        this.commandes = commandes;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Achats)) {
            return false;
        }
        Achats other = (Achats) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ecom.beans.entity.Achats[id=" + id + "]";
    }

}
